Skip to content

Add default to TypeFoldable::fold_with - #159584

Open
camsteffen wants to merge 1 commit into
rust-lang:mainfrom
camsteffen:fold-with-default
Open

Add default to TypeFoldable::fold_with#159584
camsteffen wants to merge 1 commit into
rust-lang:mainfrom
camsteffen:fold-with-default

Conversation

@camsteffen

Copy link
Copy Markdown
Contributor

TypeFoldable::fold_with delegates to TypeFoldable::try_fold_with with an infallible error type.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 20, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 20, 2026
@rustbot

This comment was marked as outdated.

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

@fmease fmease assigned fmease and unassigned dingxiangfei2009 Aug 23, 2026

@fmease fmease left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the wait! Could you rebase, then I'll issue a perf run? Otherwise looks good, amazing reduction in LOC!

Edit: I'll just rebase for you.

View changes since this review

/// infallible folders. Do not override this method, to ensure coherence
/// with `try_super_fold_with`.
fn super_fold_with<F: TypeFolder<I>>(self, folder: &mut F) -> Self;
fn super_fold_with<F: TypeFolder<I>>(self, folder: &mut F) -> Self {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test #[inline] on it locally?

/// the behavior in sync across functions.
fn fold_with<F: TypeFolder<I>>(self, folder: &mut F) -> Self;
#[inline]
fn fold_with<F: TypeFolder<I>>(self, folder: &mut F) -> Self {

@fmease fmease Aug 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Ideally we would mark this final but unfortunately this crate needs to be able to compile on stable, too. We could make it conditional on feature="nightly" using an identity macro but at this point we should just give up I guess.)

/// infallible folders. Do not override this method, to ensure coherence
/// with `try_super_fold_with`.
fn super_fold_with<F: TypeFolder<I>>(self, folder: &mut F) -> Self;
fn super_fold_with<F: TypeFolder<I>>(self, folder: &mut F) -> Self {

@fmease fmease Aug 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(similarly)

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 23, 2026
@fmease
fmease force-pushed the fold-with-default branch from a915f8c to 12bd193 Compare August 23, 2026 22:01
@rustbot

rustbot commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@fmease

fmease commented Aug 23, 2026

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 23, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 23, 2026
Add default to `TypeFoldable::fold_with`
@rust-bors

rust-bors Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 72fafa6 (72fafa63ba64b0a54986aa53d3b2508074285e19)
Base parent: fb6531d (fb6531d550e0075b9eb9a51464f404805eec87d9)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (72fafa6): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.6% [0.6%, 0.6%] 1
Regressions ❌
(secondary)
0.3% [0.2%, 0.6%] 32
Improvements ✅
(primary)
-0.3% [-0.4%, -0.2%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.1% [-0.4%, 0.6%] 4

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

Results (primary 7.2%, secondary 8.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
7.2% [5.9%, 8.4%] 2
Regressions ❌
(secondary)
12.0% [2.0%, 18.4%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.4% [-3.4%, -3.4%] 1
All ❌✅ (primary) 7.2% [5.9%, 8.4%] 2

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 469.882s -> 474.787s (1.04%)
Artifact size: 400.35 MiB -> 400.33 MiB (-0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants